<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>新增供应商</title>

</head>
<body>
<script type="text/javascript">
function saveSupplier(){
	$("#from_add_supplier").form({
		onSubmit: function(param){
			var rows = $("#bus_add_dg").datagrid("getRows");
			for(var i = 0; i < rows.length; i ++){
				param['busPeople[' + i +'].bpeoName'] = rows[i].bpeoName;
				param['busPeople[' + i +'].bpeoPhone'] = rows[i].bpeoPhone;
				param['busPeople[' + i +'].bpeoEmil'] = rows[i].bpeoEmil;
			}
			var isValid= $(this).form('validate');
			if(!isValid){
				$.messager.progress('close');	// 如果表单是无效的则隐藏进度条
			}
			return isValid;
		},
		success: function(s){
			var json = eval("(" + s + ")");
			$.messager.alert("操作提示", 
					json.success ? "操作成功" 
					: ("操作失败，原因为：" + json.reason));
			$("#from_add_supplier").form("clear");
			var rows = $("#bus_add_dg").datagrid("getRows");
			for(var i=rows.length-1;i>=0;i--){
				$('#bus_add_dg').datagrid('deleteRow', i);
			}
		}
	});
	$("#from_add_supplier").submit();
	
}
</script>
	<div class="easyui-panel" title="外包商信息" border="false" fit="true" >
		<form id="from_add_supplier" action="add_business" method="post"> 
			<table width="100%" border="0" style="padding:6px;">
    		<tr>
    			<td width="50%">
    			<input class="easyui-textbox" type="text" label="外包商名称" name="business.busName" style="width:50%"
    				data-options="required:true" />   
    			</td>
    			<td width="50%">
    				<input class="easyui-textbox" type="text" label="固定电话" name="business.busPhone" style="width:40%"
    			data-options="required:true,validType:'gdp'" />
    			</td> 			
    		</tr>
    		<tr>
    			<td width="50%">
    				<select name="business.busType" style="width:50%;"  class="easyui-combobox" label="类型" 
						data-options="panelHeight: 'auto',required:true">
								<option value="供应商">供应商</option>
					</select>
    			</td> 
    			<td width="50%" >
    				<input class="easyui-textbox" label="地址" name="business.busAddress" style="width:40%" 
    				data-options="required:true,validType:'isBlank'"/>  			
    			</td> 
    		</tr>
    	</table>
		<div class="easyui-panel" title="联系人信息" border="false" fit="true"
				style="margin: 5px">
				<table>
					<tr>
						<td width="50%"><input class="easyui-textbox" type="text"
							label="姓名" id="buspo_name" />
						</td>
					</tr>
					<tr>
						<td width="50%"><input class="easyui-textbox" type="text"
							label="电话" id="buspo_phone" style="width: 300px"
							data-options="required:true,validType:'phone'" /></td>
					</tr>
					<tr>
						<td width="50%"><input class="easyui-textbox" type="text"
							label="邮箱地址" id="buspo_emil" style="width: 300px"
							data-options="required:true,validType:'email'" /></td>
					</tr>
				</table>
				<div id="bus_tb">
						<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-add',plain:true" onclick="appendBus()">添加一行</a>
						<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-remove',plain:true" onclick="removeitBus()">删除一行</a>
				</div>
				<table style="width:100%;" id="bus_add_dg" class="easyui-datagrid" data-options="
						singleSelect: true,
						fitColumns: true, nowrap: false,
						rownumbers: true, 
						border: false,
						rownumbers: true
					">
						<thead>
							<tr>
								<th style="width:5%;" data-options="field:'xx',checkbox:true"></th>
								<th style="width:25%;" data-options="field:'bpeoName'">姓名</th>
								<th style="width:35%;" data-options="field:'bpeoPhone'">电话</th>
								<th style="width:35%;" data-options="field:'bpeoEmil'">邮箱</th>	
							</tr>
						</thead>
						
					</table>
				<div style="margin:6px;">
					<a onclick="saveSupplier()" class="easyui-linkbutton" iconCls="icon-save">保存外包商</a>
				</div>
		</div>
		</form>  
	</div>
</body>
</html>